
/*public class Solution {
//二叉树中的中序遍历
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        Deque<TreeNode> stack = new ArrayDeque<>();
        TreeNode p = root;
        while (!stack.isEmpty() || p != null) {
            while (p != null) {
                stack.push(p);
                p = p.left;
            }
            TreeNode tmp = stack.pop();
            res.add(tmp.val);
            p = tmp.right;
        }
        return res;
    }
}*/

/*class Solution {
//二叉树的最大深度
    public int maxDepth(TreeNode root) {
        public int maxDepth(TreeNode root) {
            if(root == null) {
                return 0;
            } else {
                int left = maxDepth(root.left);
                int right = maxDepth(root.right);
                return Math.max(left, right) + 1;
            }
        }
    }
}*/

/*class Solution {
//二叉树的前序遍历
    public List<Integer> preorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        if(root == null) return list;
        list.add(root.val);

        List<Integer> leftTree = preorderTraversal(root.left);
        list.addAll(leftTree);

        List<Integer> rightTree = preorderTraversal(root.right);
        list.addAll(rightTree);

        return list;
    }
}*/

/*class Solution {
//二叉树的后续遍历
    private List<Integer> ans = new ArrayList<>();

    public List<Integer> postorderTraversal(TreeNode root) {
        dfs(root);
        return ans;
    }

    private void dfs(TreeNode root) {
        if (root == null) {
            return;
        }
        dfs(root.left);
        dfs(root.right);
        ans.add(root.val);
    }
}*/
